'use strict';
var
    form = $('#test-form'),
    langs = form.find('[name=lang]'),
    selectAll = form.find('label.selectAll :checkbox'),
    selectAllLabel = form.find('label.selectAll span.selectAll'),
    deselectAllLabel = form.find('label.selectAll span.deselectAll'),
    invertSelect = form.find('a.invertSelect');

// 重置初始化状态:
form.find('*').show().off();
form.find(':checkbox').prop('checked', false).off();
deselectAllLabel.hide();
// 拦截form提交事件:
form.off().submit(function (e) {
    e.preventDefault();
    alert(form.serialize());
});
// TODO:绑定事件
//手动选
function is_checkAll(){//全选则返回true
    return langs.filter(function(){
        if($(this).prop('checked')){
            return true;
        }else{
            return false;
        }
    }).length===5;
}
langs.change(function(){
    console.log(is_checkAll());
    if(is_checkAll()){
        selectAll.prop('checked',true);
        selectAllLabel.hide();
        deselectAllLabel.show();
    }else{
        selectAll.prop('checked',false);
        selectAllLabel.show();
        deselectAllLabel.hide();
    }
 });
// 测试:
console.log('请测试功能是否正常。');